<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!doctype html>
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->

	<head>
		<title>求职天地</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<!--meta info-->
		<meta name="author" content="">
		<meta name="keywords" content="">
		<meta name="description" content="">
<style type="text/css">
	.fitem{
		margin-bottom: 15px;
	}
</style>
<script type="text/javascript">
Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
var $obj;  
$(function() {  
    $obj = $("#tt");  
    $obj.datagrid({  
        loadMsg : '数据加载中请稍后……',  
        url : '<%=path%>/emp/findMyResume',  
        //url : root + 'js/app/sysManagement/sysConfig.json',  
        fitColumns : true,  
        autoRowHeight : true,  
        pagination : true,  
        pagePosition : 'bottom',  
        pageSize : 10,  
        toolbar: '#tb',  
        pageList : [ 10, 20, 30 ],  
        border : false,  
        singleSelect:true,  
        idField:'jobId',
        				iconCls: 'icon-edit',
				pagination:true,
			collapsible:true,
			rownumbers:true,
			remoteSort : false,
                striped: true, //行背景交换
                nowap: true, //列内容多时自动折至第二行
                border: false,  
        columns : [ [ {  
                field : 'fileId',  
                title : 'fileId',  
                hidden : true  
            },{  
                field : 'resumeName',  
                title : "简历名称",  
                width : 200,  
                editor : 'text',
                sortable : true  
            },{  
                field : 'fileName',  
                title : "附件名称",  
                width : 200,  
                editor : 'text',
                sortable : true  
            },{  
                field : 'createTime',  
                title : "上传时间",  
                width : 200, 
                editor : 'text',
                sortable : true,
                formatter:function(value, row, index){
                	return new Date(value).format("yyyy-MM-dd hh:mm:ss");
                }
            },{  
                field : 'opt',  
                title : "操作",  
                width : 150,  
                align : 'center',  
                formatter:function(value,row,index){  
                 var s = '<a onclick="applyJob(\''+row.fileId + '\');" class="ope-save">选择</a> ';      
             return s;
                }
        } ] ],  
        onLoadSuccess : function(data) {  
  			
        },  
        onBeforeEdit:function(index,row){  
            row.editing = true;  
            $obj.datagrid('refreshRow', index);  
        },  
        onAfterEdit:function(index,row){  
            row.editing = false;  
            $obj.datagrid('refreshRow', index);  
        },  
        onCancelEdit:function(index,row){  
            row.editing = false;  
            $obj.datagrid('refreshRow', index);  
        }  
    });  
  
});  
	  function delResume(fileId){
		  $.messager.confirm('提示', '确定删除当前简历吗？', function(r){
				if (r){
					$.ajax({
						  type: 'post',
						  url: '<%=path%>/pdf/del',
						  data: {
							  fileId: fileId
						  },
						  success: function(data){
							  $.messager.alert('提示', '删除成功！', 'info', function() {
			          			window.location.href = '<%=path%>/emp/goResume';
			                  });
						  },
						  error: function(data){
							  
						  }
					  });
				}
			});
	  }
    function selectCurRow(obj){  
        var $a = $(obj);  
        var $tr = $a.parent().parent().parent();  
        var tmpId = $tr.find("td:eq(0)").text();  
        $obj.datagrid('selectRecord', tmpId);  
    }  
      
    function getIndexAfterDel(){  
        var selected = $obj.datagrid('getSelected');  
        var index = $obj.datagrid('getRowIndex', selected);  
        return index;  
    }  
          function findrow(index,obj){  
             selectCurRow(obj);
    } 
    function editrow(index,obj){
        selectCurRow(obj);
        var tmpIndex = getIndexAfterDel();    
        $obj.datagrid('beginEdit', tmpIndex);  
    }  
      
    function deleterow(index,obj){  
        $.messager.confirm('Confirm','确认删除?',function(r){  
            if (r){               
                selectCurRow(obj);  
                var index = getIndexAfterDel();  
                var node = $obj.datagrid('getSelected');  
                var id = node.id;   
                $.ajax({  
                    url : root + 'esbService/removeSysConfig.do?id='+id,  
                    type : 'GET',                     
                    timeout : 60000,  
                    success : function(data, textStatus, jqXHR) {     
                        var msg = '删除';  
                        if(data == 'pageData') {  
                            $obj.datagrid('deleteRow', index);  
                            return;  
                        }else if (data == "success") {  
                            $obj.datagrid('deleteRow', index);  
                            //$obj.datagrid('reload');  
                            $.messager.alert('提示', msg + '成功！', 'info', function() {  
                                //window.location.href = root + 'esbService/initSysConfig.do';  
                            });  
                        } else {  
                            $.messager.alert('提示', msg + '失败！', 'error', function() {  
                                //window.location.href = root + 'esbService/initSysConfig.do';  
                            });  
                        }  
                    }  
                });   
                  
            }  
        });  
    }  
    function saverow(index,obj){  
        selectCurRow(obj);  
        var tmpIndex = getIndexAfterDel();    
        $obj.datagrid('endEdit', tmpIndex);  
        var node = $obj.datagrid('getSelected');  
        //var data = JSON.stringify(node);  
        var json = {};  
        json.jobId = node.jobId;  
        json.jobName = node.jobName;  
        json.jobPersoncount = node.jobPersoncount;  
        json.salary   = node.salary;  
        json.jobStatus  = node.jobStatus;
          json.degree = node.degree;  
        json.address = node.address;  
        json.description = node.description;  
        json.language   = node.language;  
        json.startDate   = node.startDate;  
        json.endDate  = node.endDate;    
        $.ajax({  
            url : '<%=path%>/job/editOrSaveComJob',  
            type : 'POST',  
            data : json,  
            timeout : 60000,  
            success : function(data, textStatus, jqXHR) {     
                var msg = '';  
                if (data == 1) {  
                    $.messager.alert('提示', '保存成功！', 'info', function() {  
                        $obj.datagrid('refreshRow', tmpIndex);  
                    });  
                } else{  
                      msg = "保存失败！";  
                    $.messager.alert('提示', msg , 'error', function() {  
                        $obj.datagrid('beginEdit', tmpIndex);  
                    });  
                }                     
  
            }  
        });  
          
    }  
    function cancelrow(index,obj){  
        selectCurRow(obj);  
        var tmpIndex = getIndexAfterDel();    
        $obj.datagrid('cancelEdit', tmpIndex);  
    }  
      
    function appendRow(){  
        $obj.datagrid('appendRow',{  
            id: new Date().getTime(),  
            configName: '',  
            configNameCn: "",  
            configType: "",  
            configValue:"",  
            opt:""  
        });  
          
        var length = $obj.datagrid("getRows").length;  
        if(length > 0){  
            editIndex = length - 1;  
        }else{  
            editIndex = 0;  
        }         
        //$obj.datagrid("selectRow", editIndex);  
        $obj.datagrid("beginEdit", editIndex);  
    }  
    // 上传简历
    function addResume() {
    	$('#ddResume').dialog({
    	    title: '添加简历',
    	    width: 400,
    	    height: 250,
    	    closed: false,
    	    cache: false,
//    	    href: 'get_content.php',
    	    modal: true,
    	    buttons:'#bb'
    	});
    }
    
    function saveResume(){
    	
    }
    
    function submitForm(){
    	var tmpIndex = getIndexAfterDel();    
    	var formData = new FormData();

    	var fileVal = $('#fileName').val();
    	var resumeName = $("#resumeName").val();
    	if(!resumeName){
    		$.messager.alert('警告','请输入简历名称！');
    		return false;
    	}
    	if(!fileVal){
    		$.messager.alert('警告','请选择文件！');
    		return false;
    	}
    	
        formData.append("file",$('#fileName')[0].files[0]);
        formData.append("resumeName", $("#resumeName").val());
    	
    	$.ajax({
    		type: 'post',
    		url: '<%=path%>/pdf/upload',
    		data:formData,
    		dataType:'json',
    		async: false,
    		processData : false, // 使数据不做处理
            contentType : false, // 不要设置Content-Type请求头
            success: function(data){
            	if(data){
            		$.messager.alert('提示', '上传成功！', 'info', function() {
            			window.location.href = '<%=path%>/emp/goResume';
                    });
            	}else{
	            	$.messager.alert('警告','上传失败，请重试！', 'info', function() {  
	            		window.location.href = '<%=path%>/emp/goResume';
                    });
            	}
            },
            error: function(data){
            	$.messager.alert('警告','上传失败，请重试！', 'info', function() {  
            		window.location.href = '<%=path%>/emp/goResume';
                });
            }
    	});
    }
	</script>
	</head>
	<body>
		<!--wide layout-->
		<div class="wide_layout relative">
			<!--[if (lt IE 9) | IE 9]>
				<div style="background:#fff;padding:8px 0 10px;">
				<div class="container" style="width:1170px;"><div class="row wrapper"><div class="clearfix" style="padding:9px 0 0;float:left;width:83%;"><i class="fa fa-exclamation-triangle scheme_color f_left m_right_10" style="font-size:25px;color:#e74c3c;"></i><b style="color:#e74c3c;">Attention! This page may not display correctly.</b> <b>You are using an outdated version of Internet Explorer. For a faster, safer browsing experience.</b></div><div class="t_align_r" style="float:left;width:16%;"><a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode" class="button_type_4 r_corners bg_scheme_color color_light d_inline_b t_align_c" target="_blank" style="margin-bottom:2px;">Update Now!</a></div></div></div></div>
			<![endif]-->
			<!--markup header-->
	<!--boxed layout-->
		<div class="boxed_layout relative w_xs_auto">
			<!--[if (lt IE 9) | IE 9]>
				<div style="background:#fff;padding:8px 0 10px;">
				<div class="container" style="width:1170px;"><div class="row wrapper"><div class="clearfix" style="padding:9px 0 0;float:left;width:83%;"><i class="fa fa-exclamation-triangle scheme_color f_left m_right_10" style="font-size:25px;color:#e74c3c;"></i><b style="color:#e74c3c;">Attention! This page may not display correctly.</b> <b>You are using an outdated version of Internet Explorer. For a faster, safer browsing experience.</b></div><div class="t_align_r" style="float:left;width:16%;"><a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode" class="button_type_4 r_corners bg_scheme_color color_light d_inline_b t_align_c" target="_blank" style="margin-bottom:2px;">Update Now!</a></div></div></div></div>
			<![endif]-->
			<!--markup header-->
			<div class="col-sm-9" style="width: 750px">
			
			<div class="">
				<table id="tt" ></table>
				</div>
			</div>
			
			
			<div id="ddResume" class="easyui-dialog" title="提示"  style="width: 400px; padding: 10px 20px; height: 500px;"
		         closed="true" buttons="#dlg-buttons">                             
		         <form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
		             <div class="fitem">
		                 <label><a style="color:red ">*</a>简历名称:</label>
		                 <input id="resumeName" type="text" name="resumeName" data-options="multiline:true" style="width: 260px;"/>
		             </div>
		             <div class="fitem">
		                 <label><a style="color:red ">*</a>简历附件:</label>
		                 <input id="fileName" type="file" name="fileName" accept="application/pdf"  data-options="multiline:true" style="width: 260px;"/>
		             </div>
		             <div id="dlg-buttons" style="display: block">
		                 <a id="confirm" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="submitForm()" style="width: 90px">提交</a>
		                 <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#ddResume').dialog('close')" style="width: 90px">取消</a>
		             </div>
		         </form>
		     </div>
		     
			</div>
	    
	</body>
</html>